<template>
	<view class="ID-mian">
		<h3>身份证正面(上传)</h3>
		<view class="card-zheng">
			<view class="zheng_left" v-show="isShow">
				<image src="../../static/zheng.png" mode="" @tap='touchphoto1'></image>
			</view>
			<view class="zheng_right" v-show="!isShow">
				<image :src="V_TPID"></image>
			</view>
		</view>
		<h3>身份证反面(上传)</h3>
		<view class="card-fan">
			<view class="fan_left" v-show="isShow1">
				<image src="../../static/fan.png" mode="" @tap='touchphoto2'></image>
			</view>
			<view class="fan_right" v-show="!isShow1">
				<image :src="V_TPID1"></image>
			</view>
		</view>
		<view style="display: flex;align-items: center;margin-top: 10px;">
			<button style="width: 100%;height:40px;
			             line-height: 40px; color:white;
			             background-color: #39B54A;
						 font-size: 14px;"
						 @click="back">
						 确认上传
			</button>
		</view>
	</view>
</template>

<script>
	const util = require('@/util.js');
	export default {
			data(){
				return{
				V_TPID: '',
				V_TPID1: '',
				curl: '',
				isShow:true,
				isShow1:true,
				}
			},
			onLoad(option) {
				this.curl = 后台请求地址;
			},
			methods: {
				//上传身份证
				touchphoto1() {
					let that = this
					wx.chooseImage({
						count: 1, // 默认9
						success: function(res) {
							
							util.showLoading('图片上传中...');
							uni.request({
								url: 你的接口, 
								data: {参数},
								header: {
									//自定义请求头信息
								},
								method: 'POST',
								success: (info) => {
									if (info.data.errcode == "00000") {
										that.V_TPID = info.data.V_TPID
										that.isShow=false
										uni.showToast({
											icon: 'none',
											title: "上传成功",
											duration: 4000
										});
										util.hideLoading();
									} else {
										uni.showToast({
											icon: 'none',
											title: info.data.msg,
											duration: 4000
										});
										util.hideLoading();
									}
									util.hideLoading();
								},
								error: (info) => {
									util.hideLoading();
								},
	
	
							});
						},
					})
				},
				touchphoto2() {
					let that = this
					wx.chooseImage({
						count: 1, // 默认9
						success: function(res) {
							
							util.showLoading('图片上传中...');
							uni.request({	
							url: 接口地址。
								data: {参数},
								header: {
									 //自定义请求头信息
								},
								method: 'POST',
								success: (info) => {
									if (info.data.errcode == "00000") {
										that.V_TPID1 = info.data.V_TPID
										that.isShow1=false
										uni.showToast({
											icon: 'none',
											title: "上传成功",
											duration: 4000
										});
									} else {
										uni.showToast({
											icon: 'none',
											title: info.data.msg,
											duration: 4000
										});
										util.hideLoading();
									}
									util.hideLoading();
								},
								error: (info) => {
									util.hideLoading();
								},
							});
						}
					})
				},
			    //返回上一页
				back(){
					if(this.isShow==false && this.isShow1==false){
						uni.navigateBack()
					}else{
						uni.showToast({
							icon: 'none',
							title: "身份证信息未完善",
							duration: 4000
						});
						util.hideLoading();
					}
				}
			},
	
		}

</script>

<style lang="scss">  
	
  
</style> 
